package com.his.his_system.service.impl;

import com.his.his_system.domain.DzmHisAuthRule;
import com.his.his_system.domain.DzmHisMember;
import com.his.his_system.domain.LoginUser;
import com.his.his_system.mapper.DzmHisAuthRuleMapper;
import com.his.his_system.service.AuthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.annotation.CurrentSecurityContext;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;

import java.util.LinkedHashMap;
import java.util.List;
@Service
public class AuthServiceImpl implements AuthService {

    @Autowired
    DzmHisAuthRuleMapper dzmHisAuthRuleMapper;

    @Override
    public List<DzmHisAuthRule> getMenus() {
        LinkedHashMap<String,Object> userDetails = (LinkedHashMap<String, Object>) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        LinkedHashMap<String,Object> dzmHisMember = (LinkedHashMap<String, Object>) userDetails.get("dzmHisMember");
        return dzmHisAuthRuleMapper.selectByIdO((Integer) dzmHisMember.get("uid"));
    }
}
